package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.CashRecord;
import com.t235.gc.dao.CashRecordDao;
import com.t235.gc.biz.service.CashRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 提现记录表(CashRecord)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:20
 */
@Service("cashRecordService")
public class CashRecordServiceImpl implements CashRecordService {
    @Resource
    private CashRecordDao cashRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cashid 主键
     * @return 实例对象
     */
    @Override
    public CashRecord queryById(Long cashid) {
        return this.cashRecordDao.queryById(cashid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CashRecord> queryAllByLimit(int offset, int limit) {
        return this.cashRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cashRecord 实例对象
     * @return 实例对象
     */
    @Override
    public CashRecord insert(CashRecord cashRecord) {
        this.cashRecordDao.insert(cashRecord);
        return cashRecord;
    }

    /**
     * 修改数据
     *
     * @param cashRecord 实例对象
     * @return 实例对象
     */
    @Override
    public CashRecord update(CashRecord cashRecord) {
        this.cashRecordDao.update(cashRecord);
        return this.queryById(cashRecord.getCashid());
    }

    /**
     * 通过主键删除数据
     *
     * @param cashid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long cashid) {
        return this.cashRecordDao.deleteById(cashid) > 0;
    }
}
